import * as crypto from 'crypto'

class setCryptoSV {
  /**
   * 对输入内容进行AES加密
   */
  aesEncrypt(data: string, key: string) {
    const cipher = crypto.createCipher('aes192', key);
    let crypted = cipher.update(data, 'utf8', 'hex');
    crypted += cipher.final('hex');
    return crypted
  }

  /**
   * 对输入内容进行AES解密
   */
  aesDecrypt(data: string, key: string) {
    const decipher = crypto.createDecipher('aes192', key);
    let decrypted = decipher.update(data, 'hex', 'utf8');
    decrypted += decipher.final('utf8');
    return decrypted
  }
}

const cryptoSV = new setCryptoSV()
export default cryptoSV